package cn.com.generaldata.os.ws.impl;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.nutz.dao.entity.Record;
import org.nutz.ioc.annotation.InjectName;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cn.com.generaldata.os.service.impl.CalculateExplainService;

@Component
@InjectName
public class CalculateExplainWS {
	
	private static Logger logger = LoggerFactory.getLogger(CalculateExplainWS.class);
	
	@Autowired
	private CalculateExplainService calculateExplainService;

	@At("/calculateExplain/developmentIndex/?/?")
	@Ok("json")
	public List<Map> DevelopmentIndexSourceData(int id, String area_id){
		return calculateExplainService.getDevelopmentIndexSourceData(id, area_id);
	}
	
	@At("/calculateExplain/developmentIndexYearList/?")
	@Ok("json")
	public List<Record> DevelopmentIndexYearList(String area_id){
		return calculateExplainService.getDevelopmentIndexYearList(area_id);
	}
	
	@At("/calculateExplain/showIndicatorList/?/?")
	@Ok("jsp:/static/ocean/calculateExplain/showIndicatorList")
	public void ShowIndicatorList(int id, String area_id, HttpServletRequest request){
		
		Record re = calculateExplainService.getDevelopmentIndexById(id);
		
		List<Record> list = calculateExplainService.getIndicatorValue(re.getInt("indicator_type"), re.getString("indicator_name") , area_id);
	
		request.setAttribute("list", list);
	}
}
